import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        while (n != 0) {
            int count = 0;
            while (n > 0) {
                count += n / 3;
                n = n / 3 + n % 3;
                if (n == 2) {
                    count++;
                    n = 0;
                }
                if (n < 2) {
                    break;
                }
            }
            System.out.println(count);
            n = scanner.nextInt();
        }
    }
}
